package com.guo.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MyInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        // 统一拦截，判断是否有登录（输入有账号密码，userName就会存储到session）
        /*Object value = request.getSession().getAttribute("token");
        if (value != null) {
            return true;
        }else {
            request.getRequestDispatcher("/login.html").forward(request, response);
            return false;
        }*/
        return true;
    }



    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {

    }
}


